package com.bootdo.common.controller;

import org.wf.jwtp.provider.Token;
import org.wf.jwtp.util.SubjectUtil;

import javax.servlet.http.HttpServletRequest;

public class BaseController {
	/**
	 * 获取当前登录的userId
	 */
	public Long getLoginUserId(HttpServletRequest request) {
		Token token = getLoginToken(request);
		return token == null ? null : Long.parseLong(token.getUserId());
	}

	public Token getLoginToken(HttpServletRequest request) {
		return SubjectUtil.getToken(request);
	}
}